#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n,m;
    string s1,s2,s3,res1="",res2="";
    cin>>n;
    cin>>s1;
    cin>>m;
    cin>>s2;
    cin>>s3;
    for(int i=0;i<m;i++){
    	if(s3[i]=='D'){
    		res2+=s2[i];
    	}else{
    		res1=s2[i]+res1;
    	}
    }
    cout<<res1<<s1<<res2<<'\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}